# Contributor: Mehdi Chinoune <mehdi.chinoune@hotmail.com>

_wx_basever=3.2

_realname=wxmacmolplt
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=7.7.3
pkgrel=1
pkgdesc="An open-source gui for preparing, submitting and visualizing input and output for the GAMESS quantum chemistry package. (mingw-w64)"
arch=('any')
mingw_arch=('ucrt64' 'clang64' 'clangarm64')
url='https://brettbode.github.io/wxmacmolplt/'
msys2_repository_url="https://github.com/brettbode/wxmacmolplt"
msys2_references=(
  'aur: wxmacmolplt'
)
license=('spdx:GPL-2.0-or-later')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-glew"
         "${MINGW_PACKAGE_PREFIX}-wxwidgets${_wx_basever}-msw-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-pkgconf"  
             "${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-wxwidgets${_wx_basever}-msw")
source=("https://github.com/brettbode/wxmacmolplt/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz"
        "001-fix-building-on-mingw.patch")
sha256sums=('1a3207b30cffce418423c254b839f6914ed510c675fed5793f83bb1992e95183'
            '12ae49cc23842e6e6c89ad230c1b7e186ea378d4be911bb4d5c746fb7b2251b5')
noextract=("${_realname}-${pkgver}.tar.gz")

prepare() {
  echo "Extracting ${_realname}-${pkgver}.tar.gz..."
  tar -xzf ${_realname}-${pkgver}.tar.gz || true

  cd "${srcdir}/${_realname}-${pkgver}"
  patch -p1 -i "${srcdir}/001-fix-building-on-mingw.patch"

  autoreconf -fiv
}

build() {
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  CXXFLAGS+=" -Wno-ignored-attributes" \
  ../"${_realname}-${pkgver}"/configure \
    --prefix="${MINGW_PREFIX}" \
    --with-glew

  make
}

check() {
  cd "${srcdir}/build-${MSYSTEM}"

  make check
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"

  make install DESTDIR="${pkgdir}"

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/LICENSE" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
